package E2013;


import sun.security.rsa.RSACore;

import javax.swing.*;
import java.util.Scanner;

class stud{
    String name;
    int score;
    int no;
    static int sum;
    static int count;

    public stud() {
        super();
    }

    public void setData(){
        Scanner input = new Scanner(System.in);
        System.out.println("请输入学号：");
        no = input.nextInt();
        System.out.println("请输入姓名：");
        name = input.next();                   // 是next，不是nextline，否则会连在一起输入
        System.out.println("请输入成绩：");
        score = input.nextInt();

        sum = sum+score;
        count++;
    }

    public void display(){
        System.out.println(no+"\t"+name+"\t"+score);
    }

    public static void avg(){
        double avg = sum/count;
        System.out.println("平均分是："+avg);
    }
}
public class Exam3 {
    public static void main(String[] args) {
        stud[] stu = new stud[3];
        for(int i=0;i<stu.length;i++){
            stu[i] = new stud();
            stu[i].setData();
        }
        for (int j=0;j<stu.length;j++){
            stu[j].display();
        }
        stud.avg();
    }
}
